<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
  <meta content="yes" name=" apple-mobile-web-app-capable" />
  <!-- 隐藏状态栏  -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
  <!-- <title>申请退款</title> -->
  <link rel="stylesheet" href="css/common.css">
  <link rel="stylesheet" href="css/details.css">
</head>
<body class="ng-cloak" ng-app="CheerHiWx" ng-controller="OrderDetailRefundCtrl">
<header>
    <div class="wrapper clearfix">
      <div class="login_fl fl">
        <a href="javascript:history.back();" class="login_icon"><img src="img/srh_icon.png" alt=""></a>
      </div>
      <h1>申请退款</h1>
    </div>
</header>
<!-- 退还金额规则 -->
<section class="refund p10">
  <h2>退还金额规则</h2>
  <div class="ul_content clearfix">
    <div>
      <ul>
        <li>提前退款</li>
        <li>逾时30分钟内退款</li>
        <li>逾时30分钟后</li>
      </ul>
    </div>
    <div class="fr">
      <ul>
        <li>100%</li>
        <li>80%</li>
        <li>不可退</li>
      </ul>
    </div>
  </div>
</section>
<article class="refund_content clearfix p10">
  <div class="fl"><p>订单号：<span ng-bind="params.orderNum"></span></p></div>
  <div class="fr"><span>¥{{prepareRefund.data.cash}}</span></div>
</article>
<article class="refund_return clearfix p10 sdo">
  <div class="fl"><p>原路返回<span>3-10个工作日内退款至原支付方</span></p></div>
  <div class="fr"><p>¥{{prepareRefund.data.refundCash}}<span>{{prepareRefund.data.refundMsg}}</span></p></div>
</article>
<div class="p10"> 
  <input class="pay_btn" type="button" value="确认申请退款" ng-click="refund()">
</div>
</body>
<span style="display:none;"><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1255764485'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s95.cnzz.com/z_stat.php%3Fid%3D1255764485%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script></span>
<script src="js/jquery-1.11.2.min.js"></script>
<script src="js/angular.min.js"></script>
<script type="text/javascript" src="js/constants.js"></script>
<script src="js/common.js"></script>
<script>
  //退款
  var urlRefund = server_host + '/userweb/orderCenter/refund/pay_refund.do';
  var urlprepareRefund = server_host + '/userweb/prepareRefund.do';

  var params = base64TojsonObj(getParameterByName('params'));
  var appModule = angular.module('CheerHiWx', []);
  appModule.controller('OrderDetailRefundCtrl', ['$scope', '$http', function($scope, $http) {

    $scope.params = params;

    //加载退单信息
    $scope.loadList = function() {
      $http.get(urlprepareRefund + '?orderNum=' + params.orderNum).success(function(data, status, headers, config) {
        console.log(data);
        $scope.prepareRefund = data;

      });
    };

    $scope.refund = function(){
      $http.post(urlRefund + '?orderNum=' + $scope.params.orderNum + '&tradeNo=' + $scope.params.tradeNo).success(function(data, status, headers, config){
         console.log(data);
         if(data.data.isSuccess){
          alert('退款成功！');
          location.href = 'order-details.html?orderNum=' + $scope.params.orderNum;
         }else{
          alert(data.data.msg);
         }
        });
    }

    $scope.discount = function(price){
      return Math.round(price * 0.8 * 100) / 100;
    }

    $scope.loadList();

  }]);
</script>
<script>
    _maq.push(['_setMaq', 'order-details-refund']);
</script>
</html>